﻿using System;
using System.IO;
using BookStoreService.Core.Repository;

namespace BookStoreService.Core.Tools
{
    public static class RepositoryBuilder
    {
        private const string FolderLib = "PrototypeMVVM.Web";

        public static IRepository<T> Create<T>(string fileName) where T : class 
        {
            string localAppFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            localAppFolder = Path.Combine(localAppFolder, FolderLib);
            string usersFilePath = Path.Combine(localAppFolder, fileName);

            IRepository<T> repository = new BoCollectionToFileRepository<T>(usersFilePath);

            return repository;
        }

    }
}